/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 14:36:39
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-20 15:59:34
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/controller/teacher_attendance_controller.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:get/get.dart';

import 'components/detail_card.dart';
import 'components/detail_statistics.dart';
import 'components/month_list.dart';
import 'components/week_statistics.dart';

class TeacherDetailAttendanceScreen extends StatefulWidget {
  const TeacherDetailAttendanceScreen({Key key}) : super(key: key);
  static String routeName = "/teacher_attendance_detail";

  @override
  _TeacherDetailAttendanceScreenState createState() =>
      _TeacherDetailAttendanceScreenState();
}

class _TeacherDetailAttendanceScreenState
    extends State<TeacherDetailAttendanceScreen> {
  TeacherAttendanceController _attendanceController =
      Get.put(TeacherAttendanceController());
  int month = 0;
  @override
  void initState() {
    super.initState();
    // 发起网络请求
    _attendanceController.getTeacherStatistics();
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: buildAppBar(),
        body: SafeArea(
          child: SingleChildScrollView(
            physics: BouncingScrollPhysics(),
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 20),
              child: Column(
                children: [
                  MonthList(
                      month: month,
                      onTap: (value) {
                        setState(() {
                          month = value;
                        });
                      }),
                  SizedBox(height: 20),
                  DetailCard(),
                  SizedBox(height: 20),
                  WeekStatistics(),
                  SizedBox(height: 20),
                  DetailStatictis(),
                  SizedBox(height: 20),
                ],
              ),
            ),
          ),
        ),
      );
  AppBar buildAppBar() {
    return AppBar(
      centerTitle: true,
      backgroundColor: Colors.transparent,
      title: Text(
        "个人考勤",
        style: TextStyle(
          fontSize: 18,
        ),
      ),
      elevation: 0,
    );
  }
}
